package io.renren.modules.bus.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.bus.dao.OptometryRecordDao;
import io.renren.modules.bus.entity.OptometryRecordEntity;
import io.renren.modules.bus.service.OptometryRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("optometryRecordService")
public class OptometryRecordServiceImpl extends ServiceImpl<OptometryRecordDao, OptometryRecordEntity>
        implements OptometryRecordService {

    @Autowired
    private OptometryRecordDao dao;

    /**
     * 单表分页查询
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<OptometryRecordEntity> page = this.selectPage(
                new Query<OptometryRecordEntity>(params).getPage(),
                new EntityWrapper<OptometryRecordEntity>()
        );
        return new PageUtils(page);
    }

    /**
     * 分页查询
     */
    @Override
    public PageUtils list4Page(Map<String, Object> params){
        Page<OptometryRecordEntity> page = new Query<OptometryRecordEntity>(params).getPage();
        return new PageUtils(page.setRecords(dao.list4Page(page, params)));
    }

    /**
     * 条件查询
     */
    @Override
    public List<OptometryRecordEntity> listByCondition(Map<String, Object> params) {
        return dao.listByCondition(params);
    }

    /**
     * 逻辑删除多条记录
     */
    @Override
    public Boolean deleteLogic(List ids) {
        return dao.deleteLogic(ids);
    }

    /**
     * 根据id查询详情
     */
    @Override
    public OptometryRecordEntity queryOneById(Integer id) {
        return dao.queryOneById(id);
    }

    public List<OptometryRecordEntity> queryOneByIds(Integer id1, Integer id2){
        return dao.queryOneByIds(id1, id2);
    }

}
